package plugins

import (
	v1 "k8s.io/api/core/v1"
	"operator/pkg/types/mesh"
)

type Option func(spec *v1.PodTemplateSpec, obj *mesh.Mesh) error

type PodPlugin struct {
	opts []Option
}

func (c *PodPlugin) Add(pod *v1.PodTemplateSpec, obj *mesh.Mesh) error {
	spec := pod
	for _, fn := range c.opts {
		err := fn(spec, obj)
		if err != nil {
			return err
		}
	}

	return nil
}

func NewPodPlugin(opts ...Option) *PodPlugin {
	pp := &PodPlugin{
		opts: opts,
	}

	return pp
}
